<template>
  <div class="content">
    <div class="clear" style="padding-bottom:20px;">
      <Form :model="query" label-position="left" :label-width="100">
        <Input v-model="query.tradeId" class="w200 m-r10" placeholder="发布编号" />
        <Select placeholder="请选状态" class="w200 m-r10" v-model="query.state">
          <Option value="0">请选择状态</Option>
          <Option value="1">进行中</Option>
          <Option value="2">已结束</Option>
          <Option value="2">已领取</Option>
          <Option value="4">异常</Option>
          <Option value="5">已退还</Option>
        </Select>
        <DatePicker
          :value="dataValue"
          type="daterange"
          split-panels
          placeholder="请选择时间段"
          class="w200 m-r10"
          format="yyyy-MM-dd"
          @on-change="getTime"
        ></DatePicker>
        <Button type="primary" v-on:click="getConditionQuery()">查询</Button>
        <Button type="primary" class="fr" @click="add">添加</Button>
      </Form>
    </div>
    <!-- <Button class="daochu" type="primary" size="large" @click="exportData">
            <Icon type="ios-download-outline"></Icon>导出
    </Button>-->
    <Spin v-if="dcShow" class="demo-spin-container"></Spin>
    <Table stripe :columns="columns" :data="conditionQuery" ref="table" :loading="loading"></Table>
    <Page
      :total="info"
      show-elevator
      :page-size="pageSize"
      show-total
      @on-change="cuctGetQuery"
      :current.sync="page"
    ></Page>

    <Modal v-model="Modal.releaseModal" title="添加" width="40%">
      <Form :label-width="100" :model="addForm" :rules="rules" ref="refuse">
        <FormItem label="抽奖分类">
          <Select placeholder="请选择" class="w200 m-r10" v-model="type2">
            <Option value="1">精选</Option>
            <Option value="2">超级</Option>
          </Select>
        </FormItem>
        <FormItem label="产品">
          <Select placeholder="请选择产品" class="w200 m-r10" v-model="addForm.id">
            <Option v-for="item in optionList" :value="item.id" :key="item.id">{{ item.cnTitle }}</Option>
          </Select>
          <!-- <Input class="w-50" v-model="addForm.id" placeholder="请输入产品编号" /> -->
        </FormItem>
        <!-- <FormItem label="总份额">
					<Input class="w-50" v-model="addForm.total" placeholder="请输入总份额" />
        </FormItem>-->
        <FormItem label="开奖份额" prop="share">
          <Input class="w-50" v-model="addForm.share" placeholder="请输入开奖份额" />
        </FormItem>
        <FormItem label="花费EXUU" prop="EXUU">
          <Input class="w-50" v-model="addForm.EXUU" placeholder="请输入每份抽奖花费EXUU数量" />
        </FormItem>
        <FormItem label="领奖运费" prop="addFormCost">
          <Input class="w-50" v-model="addForm.addFormCost" placeholder="请输入领奖运费EXUU数量" />
        </FormItem>
        <FormItem label="参与开始时间">
          <DatePicker
            type="datetime"
            placeholder="请选择时间"
            v-model="joinTimeDate"
            @on-change="joinTime"
          ></DatePicker>
        </FormItem>
        <FormItem label="参与结束时间">
          <DatePicker
            type="datetime"
            placeholder="请选择时间"
            v-model="stopTimeDate"
            @on-change="stopTime"
          ></DatePicker>
        </FormItem>
        <FormItem label="开奖时间">
          <DatePicker
            type="datetime"
            placeholder="请选择时间"
            v-model="lotteryDate"
            @on-change="lottery"
          ></DatePicker>
        </FormItem>
        <FormItem label="是否重复参与">
          <Select placeholder="请选择" class="w200 m-r10" v-model="type">
            <Option value="1">是</Option>
            <Option value="2">否</Option>
          </Select>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" size="large" @click="releaseCannel">取消</Button>
        <Button type="primary" size="large" :loading="mark" @click="release">确定</Button>
      </div>
    </Modal>

    <Modal v-model="Modal.updateReleaseModal" title="修改" width="40%">
      <Form :label-width="100" :model="updateForm" :rules="updateRules" ref="refuse">
        <FormItem label="抽奖分类">
          <Select placeholder="请选择" class="w200 m-r10" v-model="type3" disabled>
            <Option value="1">精选</Option>
            <Option value="2">超级</Option>
          </Select>
        </FormItem>
        <FormItem label="产品">
          <Select placeholder="请选择产品" class="w200 m-r10" v-model="updateForm.productId" disabled>
            <Option v-for="item in optionList" :value="item.id" :key="item.id">{{ item.cnTitle }}</Option>
          </Select>
        </FormItem>
        <FormItem label="开奖份额" prop="share">
          <Input class="w-50" v-model="updateForm.share" placeholder="请输入开奖份额" disabled />
        </FormItem>
        <FormItem label="花费EXUU" prop="EXUU">
          <Input class="w-50" v-model="updateForm.EXUU" placeholder="请输入每份抽奖花费EXUU数量" disabled />
        </FormItem>
        <FormItem label="领奖运费" prop="addFormCost">
          <Input
            class="w-50"
            v-model="updateForm.addFormCost"
            placeholder="请输入领奖运费EXUU数量"
            disabled
          />
        </FormItem>
        <FormItem label="参与开始时间">
          <DatePicker
            type="datetime"
            placeholder="请选择时间"
            v-model="joinTimeDate"
            @on-change="joinTime"
            disabled
          ></DatePicker>
        </FormItem>
        <FormItem label="参与结束时间">
          <DatePicker
            type="datetime"
            placeholder="请选择时间"
            v-model="stopTimeDate"
            @on-change="stopTime"
          ></DatePicker>
        </FormItem>
        <FormItem label="开奖时间">
          <DatePicker
            type="datetime"
            placeholder="请选择时间"
            v-model="lotteryDate"
            @on-change="lottery"
          ></DatePicker>
        </FormItem>
        <FormItem label="是否重复参与">
          <Select placeholder="请选择" class="w200 m-r10" v-model="type4" disabled>
            <Option value="1">是</Option>
            <Option value="2">否</Option>
          </Select>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" size="large" @click="Modal.updateReleaseModal = false;">取消</Button>
        <Button type="primary" size="large" @click="updateRelease">确定</Button>
      </div>
    </Modal>

    <Modal v-model="Modal.supplementModal" title="补份额" width="40%">
      <Form :label-width="100" :model="addForm" :rules="rules" ref="refuse2">
        <FormItem label="发布编号" prop="title">
          <span v-text="bNumber"></span>
        </FormItem>
        <FormItem label="发布标题" prop="title">
          <span v-text="bTitle"></span>
        </FormItem>
        <FormItem label="开奖份额" prop="title">
          <span v-text="bOpenTotal"></span>
        </FormItem>
        <FormItem label="参与份额" prop="title">
          <span v-text="bValidTotal"></span>
        </FormItem>
        <!-- <FormItem label="补份额" prop='title'>
					<Input class="w-50" v-model="addForm.userName" placeholder="请输入份额" />
        </FormItem>-->
      </Form>
      <div slot="footer">
        <Button type="text" size="large" @click="supplementCannel">取消</Button>
        <Button type="primary" size="large" @click="supplement">补份额</Button>
      </div>
    </Modal>

    <Modal v-model="Modal.Participate" title="参与管理" :footer-hide="false" width="80%">
      <div style="padding-bottom:10px;">
        编号：
        <span v-text="bNumber" class="sp"></span> 标题：
        <span v-text="bTitle" class="sp"></span> 开奖份额：
        <span v-text="bOpenTotal" class="sp"></span> 参与份额：
        <span v-text="bValidTotal" class="sp"></span> 开奖幸运号：
        <span v-text="bluckyNumber" class="sp"></span>
      </div>
      <Table stripe :columns="columns2" :data="conditionQuery2" ref="table" :loading="loading"></Table>
      <Page
        :total="info2"
        show-elevator
        :page-size="pageSize2"
        show-total
        @on-change="cuctGetQuery2"
        :current.sync="page2"
      ></Page>
    </Modal>

    <Modal v-model="Modal.assign" title="指定中奖" width="558" :mask-closable="false">
      <Form :label-width="100" :model="Form" :rules="rules" ref="refuse">
        <FormItem label="幸运号码">
          <span v-text="Form.luckyNumber"></span>
        </FormItem>
        <FormItem label="发布编号">
          <span v-text="Form.number"></span>
        </FormItem>
        <FormItem label="用户ID">
          <span v-text="Form.uuid"></span>
        </FormItem>
        <div class="red" style="padding-left:40px;">*请认真检查中奖的幸运号码和用户ID是否正确，设置后将不可修改！</div>
      </Form>
      <div slot="footer">
        <Button type="text" size="large" @click="winCannel">取消</Button>
        <Button type="primary" size="large" @click="win">确定</Button>
      </div>
    </Modal>
    <Modal v-model="iddsCon" title="全盘退还" @on-ok="ok" @on-cancel="cancel">
      <p>是否全盘退还? &nbsp;编号：{{bNumber}}</p>
    </Modal>
  </div>
</template>
<script>
export default {
  data() {
    return {
      optionList: [],
      optionState: 0,
      dcShow: false,
      loading: true,
      jsonData: [],
      dataValue: ["", ""], // 时间段值
      lotteryDate: "", // 开奖时间
      joinTimeDate: "", // 活动开始时间
      stopTimeDate: "", // 活动结束时间
      type2: "", // 夺宝分类
      type: "", // 是否可以重复参与
      type3: "",
      type4: "",
      bId: "", // 补给ID
      bNumber: "", // 补给编号
      bTitle: "", // 补给标题
      bOpenTotal: "", // 开奖份额
      bValidTotal: "", // 参与份额
      bluckyNumber: "", // 开奖幸运号
      mark: false, // 防止重复提交标记
      query: {
        tradeId: "",
        state: "0",
        condition: "0"
      },
      Modal: {
        releaseModal: false,
        supplementModal: false,
        Participate: false,
        assign: false,
        updateReleaseModal: false
      },
      addForm: {
        id: "",
        total: 1,
        share: "",
        EXUU: "",
        userName: "",
        addFormCost: ""
      },
      updateForm: {
        productId: "",
        total: 1,
        share: "",
        EXUU: "",
        userName: "",
        addFormCost: ""
      },
      Form: {
        luckyNumber: "",
        number: "",
        uuid: ""
      },
      rules: {
        share: [
          {
            required: true,
            message: "请输入开奖份额",
            trigger: "blur"
          }
        ],
        EXUU: [
          {
            required: true,
            message: "请输入EXUU数量",
            trigger: "blur"
          }
        ],
        addFormCost: [
          {
            required: true,
            message: "请输入领奖运费",
            trigger: "blur"
          }
        ]
      },
      updateRules: {
        share: [
          {
            required: true,
            message: "请输入开奖份额",
            trigger: "blur"
          }
        ],
        EXUU: [
          {
            required: true,
            message: "请输入EXUU数量",
            trigger: "blur"
          }
        ],
        addFormCost: [
          {
            required: true,
            message: "请输入领奖运费",
            trigger: "blur"
          }
        ]
      },
      conditionQuery: [], // 条件查询的结果
      conditionQuery2: [], // 参与查询的结果
      info: null, // 总条数
      info2: null, // 总条数
      page: 1, // 页数
      page2: 1, // 页数
      pageSize: 15, // 每页多少条
      pageSize2: 10, // 每页多少条
      current: 1,
      idds: "",
      iddsCon: false,
      loading: true,
      downList: [],
      nb: "",
      columns: [
        {
          title: "发布编号",
          key: "number",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.number == null ? "#" : params.row.number
            );
          }
        },
        {
          title: "产品中文标题",
          key: "cnTitle",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.cnTitle == null ? "#" : params.row.cnTitle
            );
          }
        },
        {
          title: "产品英语标题",
          key: "usTitle",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.usTitle == null ? "#" : params.row.usTitle
            );
          }
        },
        {
          title: "产品越南语标题",
          key: "vnTitle",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.vnTitle == null ? "#" : params.row.vnTitle
            );
          }
        },
        {
          title: "价值(元)",
          key: "price",
          align: "center",
          render: (h, params) => {
            return h("div", params.row.price == null ? "#" : params.row.price);
          }
        },
        {
          title: "运费(EXUU)",
          key: "freight",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.freight == null ? "#" : params.row.freight
            );
          }
        },
        // {
        // 	title: '总份额',
        // 	key: 'total',
        // 	align: 'center',
        // 	render: (h, params) => {
        // 		return h('div', params.row.total == null ? '#' : params.row.total)
        // 	}
        // },
        {
          title: "EXUU",
          key: "addc",
          align: "center",
          render: (h, params) => {
            return h("div", params.row.addc == null ? "#" : params.row.addc);
          }
        },
        {
          title: "开奖份额",
          key: "openTotal",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.openTotal == null ? "#" : params.row.openTotal
            );
          }
        },
        {
          title: "参与份额",
          key: "validTotal",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.validTotal == null ? "#" : params.row.validTotal
            );
          }
        },
        {
          title: "是否重复参与",
          key: "repeated",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.repeated == null
                ? "#"
                : params.row.repeated == 1
                ? "是"
                : "否"
            );
          }
        },
        {
          title: "类型",
          key: "typeId",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.typeId == null
                ? "#"
                : params.row.typeId == 1
                ? "精选夺宝"
                : "超级夺宝"
            );
          }
        },
        {
          title: "状态",
          key: "type",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.type == null
                ? "#"
                : params.row.type == 1
                ? "进行中"
                : params.row.type == 2
                ? "已结束"
                : params.row.type == 3
                ? "已领取"
                : params.row.type == 5
                ? "已退还"
                : "异常"
            );
          }
        },
        {
          title: "开奖时间",
          key: "lotteryTime",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.lotteryTime == null
                ? "#"
                : this.stringToTime(params.row.lotteryTime)
            );
          }
        },
        {
          title: "活动开始时间",
          key: "joinTime",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.joinTime == null
                ? "#"
                : this.stringToTime(params.row.joinTime)
            );
          }
        },
        {
          title: "活动结束时间",
          key: "stopTime",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.stopTime == null
                ? "#"
                : this.stringToTime(params.row.stopTime)
            );
          }
        },
        {
          title: "添加时间",
          key: "createTime",
          align: "center",
          sortable: true,
          render: (h, params) => {
            return h(
              "div",
              params.row.createTime == null
                ? "#"
                : this.stringToTime(params.row.createTime)
            );
          }
        },
        {
          title: "操作",
          key: "action",
          width: 280,
          fixed: "right",
          align: "center",
          render: (h, params) => {
            // if(params.row.type == 1){
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.Modal.updateReleaseModal = true;
                      this.updateForm.share = params.row.openTotal;
                      this.updateForm.EXUU = params.row.addc;
                      this.updateForm.addFormCost = params.row.freight;
                      this.lotteryDate = this.stringToTime(
                        params.row.lotteryTime
                      );
                      this.joinTimeDate = this.stringToTime(
                        params.row.joinTime
                      );
                      this.stopTimeDate = this.stringToTime(
                        params.row.stopTime
                      );
                      this.updateForm.productId = params.row.productId;
                      this.updateForm.id = params.row.id;
                      this.type3 = String(params.row.typeId);
                      this.type4 = String(params.row.repeated);
                    }
                  }
                },
                "修改"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                    disabled:
                      this.conditionQuery[params.index].type !== 1 ||
                      params.row.validTotal == params.row.openTotal
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.addSupplement(
                        this.conditionQuery[params.index].id,
                        this.conditionQuery[params.index].number,
                        this.conditionQuery[params.index].title,
                        this.conditionQuery[params.index].openTotal,
                        this.conditionQuery[params.index].validTotal
                      );
                    }
                  }
                },
                "补份额"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small",
                    disabled: this.conditionQuery[params.index].type !== 4
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.backSupplement(
                        this.conditionQuery[params.index].id,
                        this.conditionQuery[params.index].number
                      );
                    }
                  }
                },
                "全盘退还"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "success",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.Participate(
                        this.conditionQuery[params.index].number,
                        this.conditionQuery[params.index].title,
                        this.conditionQuery[params.index].type,
                        this.conditionQuery[params.index].openTotal,
                        this.conditionQuery[params.index].validTotal,
                        this.conditionQuery[params.index].luckyNumber
                      );
                    }
                  }
                },
                "参与管理"
              )
            ]);
          }

          // }
        }
      ],
      columns2: [
        // {
        // 		title: '发布编号',
        // 		key: 'number',
        // 		align: 'center',
        // 		render: (h, params) => {
        // 			return h('div', params.row.number == null ? '#' : params.row.number)
        // 		}
        // 	},
        {
          title: "用户ID",
          key: "uuid",
          align: "center",
          render: (h, params) => {
            return h("div", params.row.uuid == null ? "#" : params.row.uuid);
          }
        },
        {
          title: "幸运号码",
          key: "luckyNumber",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.luckyNumber == null ? "#" : params.row.luckyNumber
            );
          }
        },
        {
          title: "状态",
          key: "status",
          align: "center",
          render: (h, params) => {
            return h(
              "div",
              params.row.status == null
                ? "#"
                : params.row.status == "1"
                ? "进行中"
                : params.row.status == "2"
                ? "已结束"
                : params.row.status == "3"
                ? "已领取"
                : params.row.status == "4"
                ? "异常"
                : "#"
            );
          }
        },
        {
          title: "记录时间",
          key: "createTime",
          align: "center",
          sortable: true,
          render: (h, params) => {
            return h(
              "div",
              params.row.createTime == null
                ? "#"
                : this.stringToTime(params.row.createTime)
            );
          }
        },
        {
          title: "操作",
          key: "action",
          width: 200,
          align: "center",
          render: (h, params) => {
            if (this.optionState == 0) {
              return h("div", [
                h(
                  "Button",
                  {
                    props: {
                      type: "primary",
                      size: "small"
                      // disabled: params.row.status !== 1? true: false
                    },
                    style: {
                      marginRight: "5px"
                    },
                    on: {
                      click: () => {
                        this.Modal.assign = true;
                        this.Form = {
                          number: params.row.number,
                          uuid: params.row.uuid,
                          luckyNumber: params.row.luckyNumber
                        };
                      }
                    }
                  },
                  "指定中奖"
                )
              ]);
            } else {
              if (params.row.control == 0) {
                return h("div", [
                  h(
                    "Button",
                    {
                      props: {
                        type: "primary",
                        size: "small",
                        disabled: params.row.control !== 1 ? true : false
                      },
                      style: {
                        marginRight: "5px"
                      },
                      on: {
                        click: () => {
                          this.Modal.assign = true;
                          this.Form = {
                            number: params.row.number,
                            uuid: params.row.uuid,
                            luckyNumber: params.row.luckyNumber
                          };
                        }
                      }
                    },
                    "指定中奖"
                  )
                ]);
              } else if (params.row.control == 1) {
                return h("div", [
                  h(
                    "Button",
                    {
                      props: {
                        type: "success",
                        size: "small",
                        disabled: params.row.control !== 1 ? true : false
                      },
                      style: {
                        marginRight: "5px"
                      },
                      on: {
                        click: () => {
                          // this.Modal.assign = true;
                          // this.Form = {
                          // 	number: params.row.number,
                          // 	uuid: params.row.uuid,
                          // 	luckyNumber: params.row.luckyNumber,
                          // }
                        }
                      }
                    },
                    "已指定"
                  )
                ]);
              }
            }
          }
        }
      ]
    };
  },
  mounted() {
    this.$Message.config({
      // 配置弹窗的位置
      top: 250
    });
    this.getQuery(); // 提现审核列表查询
    this.axios.get("publish/product").then(res => {
      if (res.data.code == 200) {
        this.optionList = res.data.data;
       
      }
    });
  },
  methods: {
    getQuery() {
      // 提现审核列表查询
      this.loading = true;
      let params = this.qs.stringify({
        current: this.page, // 当前页【可选，默认1】
        size: this.pageSize, // 每页记录数【可选，默认20】
        number: this.query.tradeId, // 编号
        type: this.query.state, // 1 进行中 2已结束 3异常
        typeId: "", // 夺宝分类 1、精选 2 超级
        luckyNumber: "", // 幸运号码
        memberId: "", // 用户id
        createStartTime: "",
        createEndTime: "",
        lotteryStartTime: "",
        lotteryEndTime: "",
        joinStartTime: "",
        joinEndStartTime: "",
        stopStartTime: "",
        stopEndTime: ""
      });
      this.axios.post("publish/select", params).then(res => {
        if (res.data.code == 200) {
          this.conditionQuery = res.data.data.records;
          // this.conditionQuery.forEach((row, index) => {
          // 	this.conditionQuery[index].createTime = '\t' + this.conditionQuery[index].createTime;
          // 	this.conditionQuery[index].coinId = this.conditionQuery[index].coinId == 0 ? 'EXUU' : '#';
          // })
          this.info = res.data.data.total;
          this.loading = false;
        }
      });
    },
    getConditionQuery() {
      // 提现审核列表条件查询
      this.loading = true;
      let params = this.qs.stringify({
        current: this.page, // 当前页【可选，默认1】
        size: this.pageSize, // 每页记录数【可选，默认20】
        number: this.query.tradeId, // 编号
        type: this.query.state, // 1 进行中 2已结束 3异常
        typeId: "", // 夺宝分类 1、精选 2 超级
        luckyNumber: "", // 幸运号码
        memberId: "", // 用户id
        createStartTime:
          this.dataValue[0] == "" ? "" : this.dataValue[0] + " 00:00:01", // 起始日期,
        createEndTime:
          this.dataValue[1] == "" ? "" : this.dataValue[1] + " 23:59:59", // 结束日期,
        lotteryStartTime: "",
        lotteryEndTime: "",
        joinStartTime: "",
        joinEndStartTime: "",
        stopStartTime: "",
        stopEndTime: ""
      });
      this.axios.post("publish/select", params).then(res => {
        if (res.data.code == 200) {
          this.conditionQuery = res.data.data.records;
          // this.conditionQuery.forEach((row, index) => {
          // 	this.conditionQuery[index].createTime = '\t' + this.conditionQuery[index].createTime;
          // 	this.conditionQuery[index].coinId = this.conditionQuery[index].coinId == 0 ? 'EXUU' : '#';
          // })
          this.info = res.data.data.total;
          this.loading = false;
        }
      });

      // this.getQuery()
      // this.page = 1;
      // this.loading = true;
      // let params = this.qs.stringify({
      // 	pn: this.page, // 当前页【可选，默认1】
      // 	size: this.pageSize, // 每页记录数【可选，默认20】
      // 	userName: this.query.userName, // 转账编号
      // 	uuid: this.query.id, // 用户 uuid
      // 	startTime: this.dataValue[0] == '' ? '' : this.dataValue[0], // 起始日期
      // 	endTime: this.dataValue[1] == '' ? '' : this.dataValue[1] // 结束日期
      // })
      // this.axios.post('publish/select', params).then(res => {
      // 	if(res.data.code == 200) {
      // 		this.conditionQuery = res.data.data.records
      // 		// this.conditionQuery.forEach((row, index) => {
      // 		// 	this.conditionQuery[index].createTime = '\t' + this.conditionQuery[index].createTime;
      // 		// 	this.conditionQuery[index].coinId = this.conditionQuery[index].coinId == 0 ? 'EXUU' : '#';
      // 		// })
      // 		this.info = res.data.data.total;
      // 		this.loading = false;
      // 	} else if(res.data.code == 401) {
      // 		this.$Message.info(res.data.msg)
      // 		localStorage.removeItem('mytoken')
      // 		this.$router.push({
      // 			name: 'login'
      // 		})
      // 	}
      // })
    },
    add() {
      // 添加商品
      this.Modal.releaseModal = true;
      this.mark = false;
    },
    release() {
      // 添加确认
      if (!this.type2) {
        this.$Message.info("请选择夺宝分类！");
        return false;
      }
      if (this.addForm.id == "") {
        this.$Message.info("请输入产品编号！");
        return false;
      }
      // if(this.addForm.total == '') {
      // 	this.$Message.info("请输入总份额！");
      // 	return false;
      // }
      if (this.addForm.share == "") {
        this.$Message.info("请输入开奖份额！");
        return false;
      }
      if (this.addForm.EXUU == "") {
        this.$Message.info("请输入抽奖花费EXUU数量！");
        return false;
      }
      if (this.addForm.addFormCost == "") {
        this.$Message.info("请输入领奖运费EXUU数量！");
        return false;
      }
      if (!this.lotteryDate) {
        this.$Message.info("请选择开奖时间！");
        return false;
      }
      if (!this.joinTimeDate) {
        this.$Message.info("请选择活动开始时间！");
        return false;
      }
      if (!this.stopTimeDate) {
        this.$Message.info("请选择活动结束时间！");
        return false;
      }
      if (!this.type) {
        this.$Message.info("请选择是否重复参与！");
        return false;
      }
      let params = this.qs.stringify({
        productId: this.addForm.id,
        total: this.addForm.total,
        openTotal: this.addForm.share,
        addc: this.addForm.EXUU,
        cost: this.addForm.addFormCost,
        lotteryTime: this.lotteryDate,
        joinTime: this.joinTimeDate,
        stopTime: this.stopTimeDate,
        repeated: this.type,
        typeId: this.type2
      });
      if (!this.mark) {
        this.mark = true;
        this.axios.post("publish/add", params).then(res => {
          if (res.data.code == 200) {
            // 添加商品成功后的处理
            this.$Message.info(res.data.msg);
            this.Modal.releaseModal = false;

            this.getQuery(); // 产品列表查询
            // 清空内容
            this.type2 = 0;
            this.type = 0;
            this.addForm.id = "";
            this.addForm.total = "";
            this.addForm.share = "";
            this.addForm.EXUU = "";
            this.lotteryDate = "";
            this.joinTimeDate = "";
            this.stopTimeDate = "";
          }
          setTimeout(() => {
            this.mark = false;
          }, 1000);
        });
      }
    },
    updateRelease() {
      if (!this.lotteryDate) {
        this.$Message.info("请选择开奖时间！");
        return false;
      }
      if (!this.stopTimeDate) {
        this.$Message.info("请选择活动结束时间！");
        return false;
      }
      let params = this.qs.stringify({
        id: this.updateForm.id,
        lotteryTime: this.stringToTime(this.lotteryDate),
        stopTime: this.stringToTime(this.stopTimeDate)
      });
      this.axios.post("publish/update", params).then(res => {
        if (res.data.code == 200) {
          // 添加商品成功后的处理
          this.$Message.info(res.data.msg);
          this.Modal.updateReleaseModal = false;
          this.getQuery(); // 产品列表查询
          // 清空内容
          this.type4 = 0;
          this.type3 = 0;
          this.updateForm.id = "";
          this.updateForm.total = "";
          this.updateForm.share = "";
          this.updateForm.EXUU = "";
          this.lotteryDate = "";
          this.joinTimeDate = "";
          this.stopTimeDate = "";
        }
      });
    },
    releaseCannel() {
      // 添加取消
      this.Modal.releaseModal = false;
      // 清空内容
      this.type2 = 0;
      this.type = 0;
      this.addForm.id = "";
      this.addForm.total = "";
      this.addForm.share = "";
      this.addForm.EXUU = "";
      this.lotteryDate = "";
      this.joinTimeDate = "";
      this.stopTimeDate = "";
    },
    addSupplement(id, number, title, openTotal, validTotal) {
      this.Modal.supplementModal = true;
      this.bId = id;
      this.bNumber = number;
      this.bTitle = title;
      this.bOpenTotal = openTotal;
      this.bValidTotal = validTotal;
    },
    backSupplement(id, number) {
      this.idds = id;
      this.bNumber = number;
      this.iddsCon = true;
    },
    ok() {
      this.iddsCon = false;
      let params = this.qs.stringify({
        publishId: this.idds
      });
      this.axios.post("publish/refund", params).then(res => {
        if (res.data.code == 200) {
          this.$Message.info(res.data.msg);
          this.getQuery();
        }
      });
    },
    cancel() {
      this.iddsCon = false;
    },
    supplement() {
      // 补份额确定
      let params = this.qs.stringify({
        publishId: this.bId
        // 'num': this.addForm.userName,
      });
      this.axios.post("publish/replenish", params).then(res => {
        if (res.data.code == 200) {
          // 添加商品成功后的处理
          this.$Message.info(res.data.msg);
          this.Modal.supplementModal = false;
          this.getQuery(); // 产品列表查询
          // 清空内容
          this.this.addForm.userName = "";
        }
      });
    },
    supplementCannel() {
      // 补份额取消
      this.Modal.supplementModal = false;

      // this.addForm.userName = '';
    },
    Participate(number, title, type, openTotal, validTotal, luckyNumber) {
      this.bNumber = number;
      this.bTitle = title;
      this.bOpenTotal = openTotal;
      this.bValidTotal = validTotal;
      this.bluckyNumber = luckyNumber;
      // alert(number+','+title)
      this.Modal.Participate = true;
      this.nb = number;
      this.getQuery2();
    },
    ParticipateCannel() {
      // 参与管理取消
      this.Modal.Participate = false;
    },
    ParticipateConfirm() {
      // 参与管理确定
      this.Modal.Participate = true;
    },
    getTime(daterange) {
      // 处理时间段时间格式
      this.dataValue = daterange;
    },
    lottery(time) {
      // 开奖时间
      this.lotteryDate = time;
    },
    joinTime(time) {
      // 活动开始时间
      this.joinTimeDate = time;
    },
    stopTime(time) {
      // 活动结束时间
      this.stopTimeDate = time;
    },
    handleSuccess(res, file) {
      this.$Message.info(res.msg);
      this.imgUrl = res.data[0].url;
    },
    Fixed(count) {
      count += "";
      let rs = count.indexOf(".");
      if (rs < 0) {
        return count + ".00";
      }
      while (count.length <= rs + 2) {
        count += "0";
      }
      return count.substr(0, rs + 3);
    },
    getQuery2() {
      // 参与管理
      let params = this.qs.stringify({
        number: this.nb,
        uuid: "",
        startTime: "", // 起始日期
        endTime: "", // 结束日期
        current: this.page2,
        size: this.pageSize2,
        status: ""
      });
      this.axios.post("/publish/join/list", params).then(res => {
        if (res.data.code == 200) {
          this.conditionQuery2 = res.data.data.list.records;
          this.optionState = res.data.data.control;
          // this.info2 = res.data.data.total;
          this.info2 = res.data.data.list.total;
        }
      });
    },
    cuctGetQuery2(page) {
      this.getQuery2();
    },
    cuctGetQuery(page) {
      this.getQuery();
    },
    winCannel() {
      this.Modal.assign = false;
    },
    win() {
      let params = this.qs.stringify({
        number: this.Form.number,
        uuid: this.Form.uuid,
        luckyNumber: this.Form.luckyNumber
      });
      this.axios.post("/publish/join/control", params).then(res => {
        if (res.data.code == 200) {
          this.Modal.assign = false;
          this.getQuery2();
          // this.conditionQuery2 = res.data.data.records;
          // this.info2 = res.data.data.total;
          this.$Message.info(res.data.msg);
        }
      });
    }
  }
};
</script>

<style scoped>
.sp {
  display: inline-block;
  padding-right: 20px;
}
</style>